<?php

namespace app\model;

use app\hospital\model\doctor;
use think\facade\Db;
use think\facade\Request;
use think\Model;

class information extends Model
{
    function search()
    {
        $key=Request::param('key');
        //  $data=Bookinfo::where("bookname","like","%".$key."%")->paginate(['list_rows'=>4,'query'=>Request::param()]);

        $data=information::withSearch(['name','department'],[
            'name'=>$key,
            'department'=>$key
        ])->paginate(['list_rows'=>3,'query'=>Request::param()]);
//        dump(Db::getlastsql());
        // halt($data->toArray());
        return $data;
    }

    function searchnameAttr($q,$v){
        //  halt($q,$v,$d);
        $q->where('name','like','%'.$v.'%');

    }
    function searchdepartmentAttr($q,$v){
        $q->whereor('department','like','%'.$v.'%');
    }
}